#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    {
        cout << "Point(int = 0, int = 0)" << endl;
    }

    //默认情况下，编译器会自动生成拷贝构造函数
    Point(const Point &rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        cout << "Point(const Point &)" << endl;
    }

    void print()
    {
        cout << "(" << _ix
             << ", " << _iy
             << ")" << endl;
    }

    //默认情况下，编译器也会自动生成析构函数
    ~Point()
    {
        cout << "~Point()" << endl;
    }

private:
    int _ix;
    int _iy;
};

void test()
{
    int a = 10;
    int b = a;

    Point pt(1, 2);//pt栈对象
    cout << "pt = ";
    pt.print();

    cout << endl;
    //拷贝(复制)构造函数
    Point pt2 = pt;//pt2也是栈对象
    cout << "pt2 = ";
    pt2.print();
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

